<%@page import="daointerfaces.DALException"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.util.List" %>
	<%@ page import="dto.OperatoerDTO" %>
	<%@ page import="dto.ProduktBatchDTO" %>
<jsp:useBean id="func" class="Function.Functions" scope="session"></jsp:useBean>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Opret Produkt Batch</title>
</head>
<body>
<div id="Centring">
<div class="sidenavn">Produkt Batches</div>
<div id="Top"><div class="menu">
			<form method="POST">
				<table width=100%> 
					<tr>
						<td>
						<%= session.getAttribute("menu") %>
						</td>
						<td align="right">
						<% 
						OperatoerDTO tempOpr = (OperatoerDTO)session.getAttribute("loginID");
						%>
						<input type="submit" name="link" value="Edit Profile" class="hyperlinkButton" size=1>
						<input type="submit" name="link" value="log out" class="hyperlinkButton">
						</td>
					</tr>
				</table>
			</form>
</div></div>
<div id="Main">
	<br>
	<hr width=95% border=1>
	<br>
	<div class="Titlelille">
	Opret Produkt Batch
	</div>
	<div class="Indhold">	
	Indtast informationer og tryk Opret 
	<br>
	<br>		
<form method="POST">

<%
List<ProduktBatchDTO> temp = func.getProduktBatchListGroup();
if (request.getMethod().equals("POST") && request.getParameter("receptId") != null) {
	if(request.getParameter("action").equalsIgnoreCase("Opret")){
		int pbId = Integer.parseInt(request.getParameter("pbId".toString()));
		int receptId = Integer.parseInt(request.getParameter("receptId"));
		int status = 0;
		int oprId = 0;
		int rbId = Integer.parseInt(request.getParameter("rbId"));
		double tara = 0;
		double netto = 0;
		String startTid = func.getTime();
		String slutTid = null;
		try{
	  		func.createProduktBatch(new ProduktBatchDTO(pbId,receptId,status,oprId,rbId,tara,netto,startTid,slutTid));			
		}catch(DALException e){
			out.print(e.getMessage());
		}
		}
	}
%>

<%
out.print("<table id=\"tabledesign\" align=center>");
out.print("<tr>");
out.print("<th>Pb Id </th>");
out.print("<th>Recept Id </th>");
out.print("<th>Rb Id </th>");
out.print("<th>Netto</th>");
out.print("</tr>");
	out.print("<tr>");
	out.print("<td>"+"<input type=\"text\" name=\"pbId\" value=\"\" size=2>"+"</td>"); 
	out.print("<td>"+"<input type=\"text\" name=\"receptId\" value=\"\" size=2>"+"</td>"); 
	out.print("<td>"+"<input type=\"text\" name=\"rbId\" value=\"\" size=2>"+"</td>");
	out.print("<td> <input type=\"submit\" name=\"action\" value=\"Opret\"> </td>");
	out.print("</tr>");
out.print("</table>");
%>
</form>
<br>
</div>
</div>
<div id="Bund"></div>
</div>	
</body>
</html>